# activeevents
# on_processing	
import psycopg2
import time
conn = psycopg2.connect("dbname=securithor user=postgres")
c = conn.cursor()

log = open('log', 'wa')

def read():
	query = "SELECT accountnumber, partitionnumber, alarmcode, arrival, zone, receiver, line, source, processed, description, type, operator, acknowledge, queue, priority, matchedalarmcode, category, pending, traffic, securithorpickup, codeprotocol, assignedoperator, frompickup FROM activeevents"
	cursor.execute(query)
	d_q1 = cursor.fetchall()

	query = "SELECT roperatorid, operatornumber, eventid, processtime FROM op_processing"
	cursor.execut(query)
	d_q2 = cursor.fetchall()

	print 'DUMP activeevents:', str(d_q1)
	log.write( 'DUMP activeevents: %s' % (str(d_q1)))
	print 'DUMP op_processing:', str(d_q2)
	log.write( 'DUMP op_processing: %s' % (str(d_q2)))

while True:
	read()
	time.sleep(5)
	print '---'
